<?php
/*
write by vomtung@yahoo.com.vn
use to test connect between server anh client by jquery
*/
 class Mobileservice_SystemModeController extends Core_Controller_Action_Standard
{
  public function indexAction()
  {
	$this->_helper->layout->disableLayout();
    $this->_helper->viewRenderer->setNoRender();
	

  }
  public function productionAction()
  {
	$this->_helper->layout->disableLayout();
    $this->_helper->viewRenderer->setNoRender();
	$global_settings_file = APPLICATION_PATH . '/application/settings/general.php';
	$generalConfig = include $global_settings_file;
	$generalConfig['environment_mode'] = 'production';
	if( (is_file($global_settings_file) && is_writable($global_settings_file)) ||
        (is_dir(dirname($global_settings_file)) && is_writable(dirname($global_settings_file))) ) {
      $file_contents = "<?php defined('_ENGINE') or die('Access Denied'); return ";
      $file_contents .= var_export($generalConfig, true);
      $file_contents .= "; ?>";
      file_put_contents($global_settings_file, $file_contents);
	  }
	$name='Production mode changed';
	$jsondata = '{  "Name":"Bob",
 "Contact":[ { "Via":"Mobile",
  "Detail":"0425795678"
  },
  { "Via":"Email",
  "Detail":"'.$name.'"
  } ],

}';
echo $_GET["callback"].'('.$jsondata.')';
  }
  public function developmentAction()
  {
 $this->_helper->layout->disableLayout();
    $this->_helper->viewRenderer->setNoRender();
	$global_settings_file = APPLICATION_PATH . '/application/settings/general.php';
	$generalConfig = include $global_settings_file;
	$generalConfig['environment_mode'] = 'development';
	if( (is_file($global_settings_file) && is_writable($global_settings_file)) ||
        (is_dir(dirname($global_settings_file)) && is_writable(dirname($global_settings_file))) ) {
      $file_contents = "<?php defined('_ENGINE') or die('Access Denied'); return ";
      $file_contents .= var_export($generalConfig, true);
      $file_contents .= "; ?>";
      file_put_contents($global_settings_file, $file_contents);
	  }
	$name='development mode changed';
	$jsondata = '{  "Name":"Bob",
 "Contact":[ { "Via":"Mobile",
  "Detail":"0425795678"
  },
  { "Via":"Email",
  "Detail":"'.$name.'"
  } ],
 "Location":"Adelaide SA"
}';
echo $_GET["callback"].'('.$jsondata.')';
	
  }
}
 ?>